package net.mfjassociates.financial.shared.domain;

import java.util.List;

import javax.persistence.PrePersist;
import javax.persistence.Query;

import static net.mfjassociates.financial.server.domain.DocumentId.getInstance;

privileged aspect Document_Fn_Entity {
	
/*	public Document.new() {
		super();
		this.iden=getInstance().getId();
	}
*/
	public static Document Document.findDocumentByIden(String iden) {
        if (iden == null) return null;
        Query query = entityManager().createQuery("select o from Document o where o.iden = :iden").setParameter("iden",iden);
        Document result = null;
        @SuppressWarnings("unchecked")
		List<Document> results = (List<Document>)query.getResultList();
        if (results.size() > 0) {
            result = (Document) results.get(0);
        }
        return result;
    }
	@PrePersist void Document.onPrePersist() {
		this.iden=getInstance().getId();
	}
    
}
